package com.dzzw.Servlet.UserServlet;

import com.dzzw.Dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/UserAttestationServlet")
public class UserAttestationServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String user_name = request.getParameter("user_id");
        String user_cardnumber = request.getParameter("user_cardnumber");
        String user_email = request.getParameter("user_email");
        String user_sex = request.getParameter("user_sex");
        String user_phone = request.getParameter("user_phone");
        String user_address = request.getParameter("user_address");
        int user_age = Integer.parseInt(request.getParameter("user_age"));
        int user_id = Integer.parseInt(request.getParameter("user_id"));
        UserDao userDao = new UserDao();
        userDao.UserAttestation(user_name,user_cardnumber,user_email,user_sex,user_phone,user_address,user_age,user_id);
        System.out.println("用户实名成功！");
        response.sendRedirect("/View/User.jsp");
    }
}
